class UsersController < ApplicationController
  
  before_filter :authenticate 
  add_breadcrumb "Principal", :root_path
  add_breadcrumb "Users", :users_path
  
  def index 
  @users = User.find(:all)
  end

  def new
  @user = User.new
  end

  def create
   @user = User.new(params[:user])
   if @user.save 
     redirect_to users_path
   else 
     render :action => 'new'
   end
  end
  
  protected
  def authenticate
  
  if session[:logged]
    if session[:tipo].upcase != 'ADM'
      redirect_to livros_path
    end  
    true
  else
    redirect_to new_session_path
  end
  
  end

end
